Websydian v6.1 online documentationOnline documentation - WebsydianExpress v3.5

Log Messages and Translatable Texts

Overview

This document explains how WebsydianExpress handles log messages, how you can extend the usage to your own application and how you can update or translate the message texts shown in the message log.

It also explains how WebsydianExpress uses translatable texts and how you can create and translate your own texts.

Log Messages

The message log is the primary tool for diagnosing and identifying errors in WebsydianExpress. WebsydianExpress writes message to the message log each time the runtime discovers an error.

Developers can also create their own message types and to write these messages to the message log from their own application.

This is done by creating a function that inherits from the abstract CreateLogMessage function. For this function, the developer must specify a text and the parameter fields that is used to generate the final text when the CreateLogMessage function is called.

The CreatelogMessage function corresponds to a message type. The identification of the message type is the implementation name of the CreateLogMessage function.

All the messages that either WebsydianExpress itself or an application has thrown are available in the message log in the administration interface.

By default, all messages thrown by WebsydianExpress itself is in English.

It is possible to translate the message texts. This can be relevant if you want it to be possible for non-English speakers to use the message log.

You also have the option to change the base text for the message. This can be relevant if you have an explanation that your administrators find it easier to understand than the standard explanation.

You can translate the texts for the messages by using the "Language support → Texts and messages" menu item in the administration interface.

Select "Log messages" as the type to show only log messages in the grid.

From this page, you can choose either to update the base text for the message or to translate the message into any language you have specified for the site.

For your own custom message types, note that until the function that writes a message to the log has been called, the message type is available for update or translation.

Parameters for the messages

In most cases, the message contain information about specific instances (e.g. users, orders etc.). As these references can be different for each message that is written to the message log, they can't be part of the base text of the message.

Instead, the message text contains a replacement marker for each parameter.

The parameter replacement markers has the format &(n:) (where n is an integer). When WebsydianExpress generates the text for the message log, it replaces these markers by the parameter values.

If any of these markers are removed, the parameter will not be included in the message shown in the message log (it will still be available if you view the details for the message).

Translatable Texts

Most of the texts shown on a standard web page are from the template that WebsydianExpress uses to generate the page. You translate these static texts by creating a version of each template for each language.

However, the application also generates other texts. Common examples are validation and error messages, which must be shown to the user as they occur. In most cases, these texts are only shown in specific situations (when errors occur or when an informational text is necessary).

WebsydianExpress uses a number of these texts - especially in the administration interface.

It is also possible to create your own custom messages.

This is done by creating a function that inherits from the abstract CreateTextMessage function. For this function, the developer must specify a text and the parameter fields that is used to generate the final text when the CreateTextMessage function is called.

You can translate these texts by using the Language support → Texts and messages menu item in the administration interface. This capability is an essential part of the language support as these texts are shown to the user.

Select "Text messages" as the type to show only texts in the grid.

From this page, you can choose to either update the base text or to translate the message into any language you have specified for the site.

For the message types you have defined yourself, note that until the function that creates a dynamic text has been called, the message type is not available for translation.

Parameters for the texts

In some cases, the text the user must see will contain information about specific instances (e.g. users, orders etc.). As these references can be different for each generated text, they can't be part of the base text.

Instead, the base text contains a replacement marker for each parameter.

The parameter replacement markers has the format &(n:) (where n is an integer). When WebsydianExpress generates the text it replaces these markers with the parameter values.

If you remove any of these markers, the parameter will not be included in the text shown to the user.

Example of use

After a user has logged in, you want to show a welcome text to him.

The text must contain the name of the user - and must be in the language of the user.

To do this, specify a base text:

Welcome &(1:) - we have special offers for you.

The function that generates this text will have the user name as input - and when it is called the user name will replace the &(1:) marker.

Finally, define a version of this text for each language you have defined for your site.

WebsydianExpress will generate the correct language version of the text (based on the language of the session).

Related Information